package org.quxiao.mmrsql.executor.test;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.quxiao.mmrsql.executor.mapper.TableJoinMapper;
import org.quxiao.mmrsql.executor.reducer.TableJoinReducer;


public class TableJoinTester {

	/**
	 * @param args
	 */
	public static void main (String[] args) throws Exception
	{
		Configuration conf = new Configuration();
		//add names of join tables
		conf.set("table1", "t1");
		conf.set("table2", "t2");
		Job job = new Job(conf, "Join Test");
		job.setJarByClass(TableJoinTester.class);
		String basePath = "/home/ubuntu/join_test/";
		FileInputFormat.addInputPath(job, new Path(basePath + "tablevalue1.in"));
		FileInputFormat.addInputPath(job, new Path(basePath + "tablevalue2.in"));
		FileOutputFormat.setOutputPath(job, new Path(basePath + System.currentTimeMillis()));
		job.setMapperClass(TableJoinMapper.class);
		job.setReducerClass(TableJoinReducer.class);
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(Text.class);
		
		System.exit(job.waitForCompletion(true) ? 0: 1);
	}

}
